home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 4363 < prev    next >
Encoding:
Text File  |  1996-08-05  |  3.0 KB  |  62 lines

  1. Newsgroups: comp.lang.c
  2. Path: howland.reston.ans.net!torn!nott!emr1!jagrant
  3. From: jagrant@emr1.emr.ca (John Grant)
  4. Subject: why not add getch() to the std C RTL?
  5. Message-ID: <DM85L8.5Jn@emr1.emr.ca>
  6. Organization: Energy, Mines, and Resources, Ottawa
  7. Date: Sun, 4 Feb 1996 00:05:32 GMT
  8.  
  9. There are *many* people who want to do the following in their C programs:
  10.     - read a single unbuffered keystroke (getch() in DOS, ioctl in unix...)
  11.     - read a directory (findfirst/findnext in DOS, readdir in unix...)
  12.     - ...
  13.  
  14. The usual response is "not standard C, o/s-specific" etc.
  15.  
  16. Ok, so why would the ANSI committee not consider implementing these things
  17. into standard C?  Yes, I know their *implementation* is O/S-specific, but
  18. that doesn't mean the function can't be part of the RTL, can it?  It is
  19. up to each vendor to implement those functions as required for their O/S.
  20. The details are irrelevant to the programmer, as long as the function exists
  21. and does as advertised.  I'm sure the ANSI folks have considered it, but
  22. why was it rejected?
  23.  
  24. The filename wildcards are O/S-specific and do not have to be part of a
  25. standard set of functions to read filenames. The directory reading stuff
  26. should just open the dir, read all entries & close it.  That would be the
  27. standard part.  After that, each programmer or vendor could write a layer
  28. over top of that which filters the filenames using the local wildcards.
  29. That would be the non-standard part.
  30.  
  31. This can't be any more O/S-specific than implementations of malloc. Management
  32. of memory is a *very* O/S-specific thing and is implemented differently on
  33. every different O/S.  If they can make malloc() a standard, why can't they
  34. make some sort of getch() a standard too?
  35.  
  36. I can't believe that there are *reasonably modern* O/S out there that do not
  37. allow a single keystroke of input or that do not have any way of obtaining a
  38. list of filenames. DOS can do it & unix can do it.  I have done this on
  39. Data General AOS/VS & VAX/VMS.  Or is there a UNIVAC out there that can't
  40. do it, so the ANSI committee won't consider it?  Let me guess, it's the
  41. IBM synchronous terminal I/O that's keeping us in the Dark Ages, right?
  42.  
  43. I've seen many suggestions here to obtain the curses package in order to
  44. get a function to read a single keystroke.  That seems a bit silly.
  45. I really don't think there's much place in this modern GUI world (any O/S)
  46. for all of that 20-year old curses stuff, but the single keystroke function
  47. is extremly useful.  Besides, whether or not curses is available on
  48. 20 different systems doesn't change the fact that it is still not part of
  49. the language.
  50.  
  51. If languages can define specific syntax for things like fixed-length records,
  52. variable-length records etc (as in FORTRAN), then why can't a language (any
  53. language) also define a specific syntax or standard function to read a
  54. single keystroke. It's just a different type of 'record'.
  55.  
  56. Has the ANSI committee for C decided to 'freeze' the language and not develop
  57. the standard RTL any further?
  58. -- 
  59. John A. Grant                        jagrant@emr1.emr.ca
  60. Airborne Geophysics
  61. Geological Survey of Canada, Ottawa
  62.